package{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	public class Ruler extends Sprite{
		private var split:int=50;
		public function Ruler()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
		}
		private function addToStage(e:Event):void{
			this.update();
		}
		public function update():void{
			this.removeChildren();
			var w:int=this.stage.stageWidth;
			var h:int=this.stage.stageHeight;
			for(var i:int=0;i<Math.floor(w/split);i++){
				var sp:Sprite=new Sprite;
				sp.graphics.lineStyle(1,0x999999,0.2);
				sp.graphics.moveTo(i*split,0);
				sp.graphics.lineTo(i*split,h);
				this.addChild(sp);
				var txt:TextField=new TextField();
				txt.text=(i*split).toString();
				txt.x=i*split;
				txt.textColor=0x000000;
				txt.mouseEnabled=false;
				sp.mouseEnabled=false;
				this.addChild(txt);
			}
			for(var j:int=0;j<Math.floor(h/split);j++){
				var sp:Sprite=new Sprite;
				sp.graphics.lineStyle(1,0x999999,0.2);
				sp.graphics.moveTo(0,j*split);
				sp.graphics.lineTo(w,j*split);
				this.addChild(sp);
				var txt:TextField=new TextField();
				txt.text=(j*split).toString();
				txt.y=j*split;
				txt.textColor=0x000000;
				txt.mouseEnabled=false;
				sp.mouseEnabled=false;
				this.addChild(txt);
			}
		}
	}
}